<!DOCTYPE HTML><html lang="en">
<HEAD>

<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >

<meta charset="utf-8">
<LINK REL="STYLESHEET" HREF="../book.css" TYPE="text/css">
<TITLE>
FormText control
</TITLE>
</HEAD>
<BODY>

<H1>
FormText control</H1>
<p>It is possible to achieve highly polished results using images, 
hyperlinks and text snippets mixed together in a form. However, when the mix of 
these elements is needed as part of one integral text, it is very hard to do. To 
remedy the problem, UI Forms offer a rudimentary text control that can do the 
following:</p>
<ul>
	<li>
	<p>Render plain wrapped text</p></li>
	<li>
	<p>Render plain text but convert any segment that starts with
	<b>http://</b> into a hyperlink on the fly</p></li>
	<li>
	<p>Render text with XML tags</p></li>
</ul>
<p>In all the modes, <code>FormText</code> control is capable of 
rendering either a string or an input stream.</p>
<h2>Rendering Normal Text (label Mode)</h2>
<div>
	<pre>	FormText rtext = toolkit.createFormText(form.getBody(), true);
	String data = &quot;Here is some plain text for the text to render.&quot;;
	rtext.setText(data, false, false);</pre>
</div>
<div>
	<p>Second argument set to <code>false</code> means that we will 
	treat input text as-is, and the third that we will not try to expand URLs if 
	found.</p></div>
<div>
	<h2>Automatic Conversion of URLs Into Hyperlinks</h2>
	<p>It is possible to still handle the text as normal but automatically 
	convert segments with http:// protocol into hyperlinks:</p>
	<pre>	FormText rtext = toolkit.createFormText(form.getBody(), true);
	String data = &quot;Here is some plain text for the text to render; &quot;+
                       &quot;this text is at http://www.eclipse.org web site.&quot;;
	rtext.setText(data, false, <b>true</b>);</pre>
	<p>Similar to the <code>Hyperlink</code> control, <code>
	FormText</code> accepts listeners that implement <code>HyperlinkListener</code>. 
	These listeners will be notified about events related to the hyperlink 
	segments within the control.</p></div>
</BODY>
</HTML>
